package meijuli.com.join51.business.service;

import com.jhx.common.http.HttpResponse;
import com.jhx.common.model.Photos;
import com.jhx.common.model.User;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import meijuli.com.join51.business.aliyun.AliOSS;
import meijuli.com.join51.business.model.AgentsLogin;
import meijuli.com.join51.business.model.Announcement;
import meijuli.com.join51.business.model.AppBean;
import meijuli.com.join51.business.model.BankCard;
import meijuli.com.join51.business.model.BankMsg;
import meijuli.com.join51.business.model.BussinessCategory;
import meijuli.com.join51.business.model.Category;
import meijuli.com.join51.business.model.ClientList;
import meijuli.com.join51.business.model.Commodity;
import meijuli.com.join51.business.model.CommodityData;
import meijuli.com.join51.business.model.HomeMessage;
import meijuli.com.join51.business.model.Message;
import meijuli.com.join51.business.model.Order;
import meijuli.com.join51.business.model.PayPrice;
import meijuli.com.join51.business.model.PayResult;
import meijuli.com.join51.business.model.PayTypeObj;
import meijuli.com.join51.business.model.PlatformDiscount;
import meijuli.com.join51.business.model.RecommendObject;
import meijuli.com.join51.business.model.ResFlowObj;
import meijuli.com.join51.business.model.SmsCode;
import meijuli.com.join51.business.model.Status;
import meijuli.com.join51.business.model.TeamCount;
import meijuli.com.join51.business.model.UserData;
import meijuli.com.join51.business.model.WalletData;
import meijuli.com.join51.business.model.Withdraw;
import meijuli.com.join51.business.model.WithdrawRule;
import meijuli.com.join51.business.model.serviceprovide.OrderData;
import meijuli.com.join51.business.model.serviceprovide.OrderPayData;
import meijuli.com.join51.business.model.serviceprovide.PayInfo;
import meijuli.com.join51.business.model.serviceprovide.ServiceProviderPayStatus;
import meijuli.com.join51.business.model.serviceprovide.ServiceShopData;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.HeaderMap;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

/**
 * 接口管理类
 * <p>
 *
 * @author wenqin 2017-04-13 19:35
 */

public interface ApiService {

    /**
     * 登录
     *
     * @param mobile   手机
     * @param password 密码（加密）
     * @param userType 类型
     * @param map      可缺省参数，用户信息
     */
    @POST("businessCenter/login")
    Call<HttpResponse<UserData>> login(@Query("phone") String mobile,
                                       @Query("password") String password,
                                       @Query("userType") int userType,
                                       @QueryMap Map<String, String> map);

    /**
     * 获取验证码
     *
     * @param mobile  电话
     * @param smsType 1 表示注册，2 表示找回密码, 3设置密码
     */
    @POST("getSmsCode/getSms")
    Call<HttpResponse<SmsCode>> getSmsCode(@Query("phone") String mobile,
                                           @Query("smsType") int smsType);

    /**
     * 注册
     *
     * @param authCode 验证码
     * @param password 密码（加密）
     * @param userType 1表示个人版，2表示商家版
     * @param recommendId 缺省参数，传推荐人ID
     */
    @POST("regist/userRegist")
    Call<HttpResponse<UserData>> register(@Query("phone") String phone,
                                          @Query("code") String authCode,
                                          @Query("password") String password,
                                          @Query("userType") int userType,
                                          @Query("recommendId") String recommendId,
                                          @HeaderMap Map<String, String> map);

    /**
     * 找回密码
     *
     * @param password 加密密码
     */
    @POST("businessCenter/modifypassword")
    Call<HttpResponse<SmsCode>> findPw(@Query("phone") String phone,
                                       @Query("code") String code,
                                       @Query("password") String password);

    /**
     * 获取支持的银行列表
     */
    @GET("bank/getSysBankCategory")
    Call<HttpResponse<List<BankCard>>> getBankCardList();

    /**
     * 提交用户信息
     */
    @FormUrlEncoded
    @POST("businessCenter/completeBusinessInfo")
    Call<HttpResponse<String>> pushUserInfo(@FieldMap Map<String, String> map);

    /**
     * 获取认证状态 等信息
     */
    @GET("businessCenter/getAuthStatus")
    Call<HttpResponse<Status>> getAuthStatus();

    @GET("businessCenter/logout")
    Call<HttpResponse> logOut();


    /**
     * 获取商品列表
     */
    @GET("businessCenter/getBusinessGoodsList")
    Call<HttpResponse<CommodityData>> getCommodityList(@Query("status") Integer status,
                                                       @Query("oneCategoryId") String oneCategoryId,
                                                       @Query("pageIndex") int pageIndex,
                                                       @Query("pageSize") int pageSize);

    /**
     * 上架、下架商品
     *
     * @param oneCategoryId  分类ID
     * @param status:        状态 默认 =1
     * @param finalPrice：成本
     * @param picture：       图片数组
     * @param price          : 售价
     * @param mainPicture：主图
     * @param sales：         库存
     * @param goodsDesc：商品描述
     * @param goodsName：商品名称
     */
    @FormUrlEncoded
    @POST("businessCenter/updateOrsaveBusinessGoods")
    Call<HttpResponse<String>> offCommodity(@Field("dmId") String id,
                                            @Field("oneCategoryId") String oneCategoryId,
                                            @Field("status") String status,
                                            @Field("finalPrice") String finalPrice,
                                            @Field("price") String price,
                                            @Field("picture") String picture,
                                            @Field("mainPicture") String mainPicture,
                                            @Field("sales") String sales,
                                            @Field("goodsDesc") String goodsDesc,
                                            @Field("goodsName") String goodsName,
                                            @Field("oneCategoryName") String oneCategoryName,
                                            @Field("brandId") String brandId,
                                            @Field("twoCategoryId") String twoCategoryId,
                                            @Field("businessId") String businessId,
                                            @Field("createTime") String createTime,
                                            @Field("createUserId") String createUserId,
                                            @Field("isRecommend") String isRecommend,
                                            @Field("sort") String sort,
                                            @Field("shelvesTime") String shelvesTime);

    /**
     * 新增商品
     * 修改商品
     *
     * @param oneCategoryId  分类ID
     * @param status:        状态 默认 =1
     * @param finalPrice：成本
     * @param picture：       图片数组
     * @param price          : 售价
     * @param mainPicture：主图
     * @param sales：         库存
     * @param goodsDesc：商品描述
     * @param goodsName：商品名称
     */
    @FormUrlEncoded
    @POST("businessCenter/updateOrsaveBusinessGoods")
    Call<HttpResponse<String>> addCommodity(@Field("dmId") String id,
                                            @Field("oneCategoryId") String oneCategoryId,
                                            @Field("status") String status,
                                            @Field("finalPrice") String finalPrice,
                                            @Field("price") String price,
                                            @Field("picture") String picture,
                                            @Field("mainPicture") String mainPicture,
                                            @Field("sales") String sales,
                                            @Field("goodsDesc") String goodsDesc,
                                            @Field("goodsName") String goodsName);

    /**
     * 重新定位
     */
    @FormUrlEncoded
    @POST("businessCenter/reCoordinate")
    Call<HttpResponse<User>> changeAddress(@Field("longitude") double longitude,
                                           @Field("latitude") double latitude,
                                           @Field("address") String address,
                                           @Field("dmId") long dmId,
                                           @Field("shopAdd") String shopAdd);

    /**
     * 获取分类列表
     *
     * @param queryMap 传"status" Category status_open
     */
    @GET("businessCenter/getBusinessGoodsCategoryList")
    Call<HttpResponse<List<Category>>> getCategoryList(@QueryMap Map<String, String> queryMap);

    /**
     * 创建分类
     *
     * @param sort   排序
     * @param status 0 开启 1 关闭
     */
    @FormUrlEncoded
    @POST("businessCenter/addBusinessGoodsCategory")
    Call<HttpResponse<String>> newCategory(@Field("categoryName") String categoryName,
                                           @Field("sort") int sort,
                                           @Field("status") int status);

    /**
     * 更新分类
     *
     * @param status 状态
     * @param dmId   分类Id
     */
    @FormUrlEncoded
    @POST("businessCenter/updateBusinessGoodsCategory")
    Call<HttpResponse<String>> updateCategory(@Field("categoryName") String categoryName,
                                              @Field("sort") int sort,
                                              @Field("status") int status,
                                              @Field("dmId") String dmId);

    /**
     * 检查更新
     */
    @GET("version/now")
    Call<HttpResponse<AppBean>> checkUpdate(@Query("appType") int appType,
                                            @Query("userType") int userType,
                                            @Header("versionName") String versionName,
                                            @Header("versionCode") int versionCode,
                                            @Header("sdkVersion") int sdkVersion);

    /**
     * 获取用户状态
     */
    @GET("businessCenter/getBusinessInfo")
    Call<HttpResponse<UserData>> getUserInfo();

    /**
     * 获取商品详情
     */
    @GET("businessCenter/detail")
    Call<HttpResponse<Commodity>> getCommodity(@Query("dmId") String dmId);


    /** --------------- 订单管理 --------------- **/

    /**
     * 获取线下支付列表
     */
    @FormUrlEncoded
    @POST("businessCenter/getOffLineOrderList")
    Call<HttpResponse<List<Order>>> getOrders(@Field("orderStatus") String orderStatus,
                                              @Field("pageIndex") int pageIndex,
                                              @Field("pageSize") int pageSize);

    /**
     * 钱包
     */
    @GET("businessCenter/getUserWallet")
    Call<HttpResponse<WalletData>> getWalletData();

    /**
     * 获取流水信息
     */
    @FormUrlEncoded
    @POST("businessCenter/getRunsubFrozenFlowByType")
    Call<HttpResponse<List<ResFlowObj>>> getRusSubFrozen(@Field("nowPage") int nowPage,
                                                         @Field("pageSize") int pageSize,
                                                         @FieldMap HashMap<String, String> map);

    @FormUrlEncoded
    @POST("businessCenter/getRunsubFlowByType")
    Call<HttpResponse<List<ResFlowObj>>> getRunSub(@Field("nowPage") int nowPage,
                                                   @Field("pageSize") int pageSize,
                                                   @FieldMap HashMap<String, String> map);

    @FormUrlEncoded
    @POST("businessCenter/getGoodsMoneyFlowByType")
    Call<HttpResponse<List<ResFlowObj>>> getGoodsMoney(@Field("nowPage") int nowPage,
                                                       @Field("pageSize") int pageSize,
                                                       @FieldMap HashMap<String, String> map);

    /**
     * 冻结货款流水
     * @param nowPage
     * @param pageSize
     * @return
     */
    @FormUrlEncoded
    @POST("businessCenter/getFrozenGoodsMoneyFlowByType")
    Call<HttpResponse<List<ResFlowObj>>> getFreezeMoney(@Field("nowPage") int nowPage,
                                                        @Field("pageSize") int pageSize,
                                                        @FieldMap HashMap<String, String> map);

    /**
     * 冻结银子流水
     * @param nowPage
     * @param pageSize
     * @return
     */
    @FormUrlEncoded
    @POST("businessCenter/getFrozenSilverMoneyFlowByType")
    Call<HttpResponse<List<ResFlowObj>>> getFrozenSilver(@Field("nowPage") int nowPage,
                                                         @Field("pageSize") int pageSize,
                                                         @FieldMap HashMap<String, String> map);

    /**
     * 银子流水
     * @param nowPage
     * @param pageSize
     * @return
     */
    @FormUrlEncoded
    @POST("businessCenter/getSilverMoneyFlowByType")
    Call<HttpResponse<List<ResFlowObj>>> getSilver(@Field("nowPage") int nowPage,
                                                   @Field("pageSize") int pageSize,
                                                   @FieldMap HashMap<String, String> map);

    @FormUrlEncoded
    @POST("businessCenter/getFrozenGoodsMoneyFlowByType")
    Call<HttpResponse<List<ResFlowObj>>> getGoodsMoneyFrozen(@Field("nowPage") int nowPage,
                                                             @Field("pageSize") int pageSize,
                                                             @FieldMap HashMap<String, String> map);

    /**
     * 兑换明细
     *
     * @param map 传递date
     * @return
     */
    @FormUrlEncoded
    @POST("businessCenter/getBusinessExtractFlow")
    Call<HttpResponse<List<ResFlowObj>>> getBusinessExtractFlow(@Field("nowPage") int nowPage,
                                                                @Field("pageSize") int pageSize,
                                                                @FieldMap HashMap<String, String> map);

    @GET("businessCenter/getBusinessBankCard")
    Call<HttpResponse<BankMsg>> getBankCard();

    /**
     * 添加银行卡
     *
     * @param IDCardNum   身份证
     * @param bankName    银行名称
     * @param bankCardNum 卡号
     * @param realName    持卡人
     */
    @FormUrlEncoded
    @POST("businessCenter/businessBankCardBinding")
    Call<HttpResponse<BankMsg>> bindBankCard(@Field("IDCardNum") String IDCardNum,
                                             @Field("bankName") String bankName,
                                             @Field("bankId") long bankID,
                                             @Field("bankCardNum") String bankCardNum,
                                             @Field("realName") String realName,
                                             @Field("cityId") long cityId,
                                             @Field("city") String city,
                                             @Field("province") String province,
                                             @Field("provinceId") long provinceId);

    @FormUrlEncoded
    @POST("businessCenter/businessBankCardChange")
    Call<HttpResponse<BankMsg>> changeBankCard(@Field("IDCardNum") String IDCardNum,
                                               @Field("bankName") String bankName,
                                               @Field("bankId") long bankID,
                                               @Field("bankCardNum") String bankCardNum,
                                               @Field("realName") String realName,
                                               @Field("cityId") long cityId,
                                               @Field("city") String city,
                                               @Field("province") String province,
                                               @Field("provinceId") long provinceId);

    /**
     * 删除银行卡
     */
    @GET("businessCenter/deleteBusinessBankCard")
    Call<HttpResponse<String>> delBankCard(@Query("dmId") String dmId,
                                           @Query("paymentPassword") String paymentPassword);

    @GET("businessCenter/getmywallet")
    Call<HttpResponse<Withdraw>> getWalletMsg();

    /**
     * 提现
     *
     * @param amount
     * @param type
     * @param paymentPassword
     * @return
     */
    @FormUrlEncoded
    @POST("businessCenter/addBusinessExtract")
    Call<HttpResponse<Object>> withdraw(@Field("amount") String amount,
                                        @Field("type") String type,
                                        @Field("paymentPassword") String paymentPassword);

    /**
     * 判断是否设置支付密码
     */
    @GET("businessCenter/getBusinessPayment")
    Call<HttpResponse<String>> getPayPwd();

    /**
     * 设置或修改支付密码
     */
    @FormUrlEncoded
    @POST("businessCenter/saveOrUpdateUserPayPwd")
    Call<HttpResponse<String>> setOrUpdatePwd(@Field("paymentPassword") String paymentPassword,
                                              @Field("phone") String phone,
                                              @Field("code") String code);

    /**
     * 重置登录密码
     * @param oldPwd 旧密码
     * @param newPwd 新密码
     * @return
     */
    @FormUrlEncoded
    @POST("businessCenter/resetsPwd")
    Call<HttpResponse<String>> resetLoginPwd(@Field("oldPwd") String oldPwd,
                                             @Field("newPwd") String newPwd);

    /**
     * 修改用户头像
     * @param headImg
     * @return
     */
    @FormUrlEncoded
    @POST("businessCenter/rechangeBusinessHeadImg")
    Call<HttpResponse<String>> uploadHeadIcon(@Field("headImg") String headImg);

    /**
     * 添加联系人
     */
    @GET("businessCenter/addRecommender")
    Call<HttpResponse<RecommendObject>> addRecommenderUser(
            @Query("recommendPhone") String recommendPhone);

    /**
     * 获取推荐人信息
     */
    @GET("businessCenter/getRecommendUser")
    Call<HttpResponse<RecommendObject>> getClientInfo(
            @Query("recommendPhone") String recommendPhone);

    /**
     * 获取团队数量
     */
    @GET("businessCenter/getTeamCountNum")
    Call<HttpResponse<TeamCount>> getTeamCount();

    /**
     * 获取团队信息
     */
    @GET("businessCenter/getMyTeamfans")
    Call<HttpResponse<ClientList>> getMyTeamFans();

    /**
     * 获取的店铺类别
     */
    @GET("businessCenter/getBusinessCategoryList")
    Call<HttpResponse<List<BussinessCategory>>> getBusinessCategoryList();

    /**
     * 获取消息
     *
     * @return
     */
    @GET("getNotict")
    Call<HttpResponse<List<Message>>> getMessageList(@Query("userId") String userId,
                                                     @Query("nowPage") int nowPage,
                                                     @Query("pageSize") int pageSize);

    /**
     * 获取公告
     *
     * @param nowPage
     * @return
     */
    @GET("getAnnouncement")
    Call<HttpResponse<List<Announcement>>> getAnnouncement(@Query("userId") String userId,
                                                           @Query("nowPage") int nowPage,
                                                           @Query("pageSize") int pageSize);

    /**
     * 获取首页代理商登录
     */
    @GET("home/getAgentLoginInterface")
    Call<HttpResponse<AgentsLogin>> getAgentLogin();

    /**
     * 获取首页提示信息
     */
    @GET("businessCenter/getExpireTimeTips")
    Call<HttpResponse<HomeMessage>> getMessage();

    /**
     * 支付方式列表
     */
    @GET("businessCenter/getCashPayType")
    Call<HttpResponse<PayTypeObj>> getPaymentList();

    /**
     * 获取支付金额
     */
    @GET("businessCenter/getBusinessRecharge")
    Call<HttpResponse<List<PayPrice>>> getPayPriceList();

    /**
     * 预购支付
     */
    @GET("businessCenter/generalRechargeQR")
    Call<HttpResponse<PayResult>> getPayResult(@Query("rechargeId") long rechargeId,
                                               @Query("payType") int payType);

    /**
     * 查询支付
     */
    @GET("businessCenter/queryOrderResult")
    Call<HttpResponse<String>> checkPayment(@Query("outTradeNo") String outTradeNo);

    /**
     * 修改商家名称
     */
    @FormUrlEncoded
    @POST("businessCenter/changeSellerName")
    Call<HttpResponse<String>> changeSellerName(@Field("name") String name);

    /**
     * 获取平台扣点列表
     */
    @GET("businessCenter/pushBusinessDiscountRules")
    Call<HttpResponse<PlatformDiscount>> getPlatformDiscount();

    /**
     * 修改平台扣点
     */
    @FormUrlEncoded
    @POST("businessCenter/updateBusinessDiscount")
    Call<HttpResponse<String>> updatePlatformDiscount(@Field("discountId") String discountId,
                                                      @Field("discountNum") String discountNum);

    /**
     * 获取商家相册列表
     */
    @FormUrlEncoded
    @POST("businessCenter/getBusinessAlbumList")
    Call<HttpResponse<Photos>> getBusinessAlbumList(@Field("nowPage") String nowPage,
                                                    @Field("pageSize") String pageSize);
    /**
     * 上传商家相册图片
     *
     * @param albumPhotos 阿里云图片链接，多张用‘，’号分割
     */
    @FormUrlEncoded
    @POST("businessCenter/uploadBusinessPhoto")
    Call<HttpResponse<String>> uploadBusinessPhoto(@Field("albumPhotos") String albumPhotos);

    /**
     * 删除商家图片
     * @param dmId
     */
    @FormUrlEncoded
    @POST("businessCenter/deleteBusinessAlbumById")
    Call<HttpResponse<String>> deleteBusinessAlbumById(@Field("dmId") String dmId);

    /**
     * 获取兑换规则表
     */
    @GET("wallet/business/userWallet/getExtractRuleList")
    Call<HttpResponse<List<WithdrawRule>>> getWithdrawRuleList();

    /**
     * 获取支付列表
     *
     * @param typeC 5 获取 商家升级品牌服务商支付方式
     * @return 支付列表
     */
    @GET("wallet/business/payType/getCashPayType")
    Call<HttpResponse<PayInfo>> getPayList(@Query("typeC") String typeC);

    /**
     * 获取品牌服务商列表
     *
     * @return 列表
     */
    @GET("goods/public/business/spMerchandise/getSpMerchandiseList")
    Call<HttpResponse<ServiceShopData>> getServiceShopList();

    /**
     * 品牌服务商下单
     *
     * @return 列表
     */
    @GET("order/orderSp/subOrder")
    Call<HttpResponse<OrderData>> serviceShopSubOrder(@Query("spSettingId") String spSettingId,
                                                      @Query("businessPhone") String businessPhone);

    /**
     * 获取OSS参数
     * @return
     */
    @GET("businessCenter/getOssServer")
    Call<HttpResponse<AliOSS>> getOSS();

    /**
     * 获品牌服务商升级支付参数
     *
     * @return 列表
     */
    @GET("order/orderSp/getOrderPay")
    Call<HttpResponse<OrderPayData>> getOrderPay(@Query("orderId") String orderId,
                                                 @Query("payType") String payType);
    /**
     * 获品牌服务商升级支付结果
     *
     * @return 支付结果
     */
    @GET("order/orderSp/queryResult")
    Call<HttpResponse<ServiceProviderPayStatus>> getServiceProviderPayStatus(@Query("outTradeNo") String outTradeNo);
}
